//礼物的最大价值
import java.util.*;


public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     *
     * @param grid int整型二维数组
     * @return int整型
     */
    public int maxValue (int[][] grid) {
        // write code here
        int len = grid[0].length;
        int row = grid.length;
        for (int i = 1; i < row; i++) {
            grid[i][0] += grid[i - 1][0];
        }
        for (int j = 1; j < len; j++) {
            grid[0][j] += grid[0][j - 1];
        }
        for (int i = 1; i < row; i++) {
            for (int j = 1; j < len; j++) {
                grid[i][j] += Math.max(grid[i - 1][j], grid[i][j - 1]);
            }
        }
        return grid[row - 1][len - 1];
    }
}
import java.util.*;


public class Solution {

    public int[] findDisappearedNumbers (int[] nums) {
        // write code here
        int[] arr = new int[nums.length];
        for (int i = 0; i < nums.length; i++){
            arr[nums[i]-1]++;
        }
        int count = 0;
        for (int i = 0; i < nums.length; i++){
            if (arr[i] == 0){
                count++;
            }
        }
        int[] ret = new int[count];
        int k = 0;
        for (int i = 0; i < nums.length; i++){
            if (arr[i] == 0){
                ret[k++] = i+1;
            }
        }

        return ret;
    }
}
import java.util.*;


public class Solution {

    public int[] getRow (int num) {
        // write code here
        int[][] ret = new int[num+1][];
        for (int i = 0; i <= num; i++){
            ret[i] = new int[i+1];
            for (int j = 0; j <= i; j++){
                if (j == 0 || j == i){
                    ret[i][j] = 1;
                }else {
                    ret[i][j] = ret[i-1][j] + ret[i-1][j-1];
                }
            }
        }
        return ret[num];
    }
}
import java.util.*;


public class Solution {

    public int[][] generate (int num) {
        // write code here
        int[][] ret = new int[num][];
        for (int i = 0; i < num; i++){
            ret[i] = new int[i+1];
            for (int j = 0; j <= i; j++){
                if (j == 0 || j == i){
                    ret[i][j] = 1;
                }else {
                    ret[i][j] = ret[i-1][j] + ret[i-1][j-1];
                }
            }
        }
        return ret;
    }
}
import java.util.*;


public class Solution {

    public int getDis (int[] A, int n) {
        // write code here
        int max = 0;
        int a = 0;

        for (int i = 1; i < n; i++){
            if (A[i] - A[a] > max){
                max = A[i] - A[a];
            }
            if (A[i] < A[a]){
                a = i;
            }
        }

        return max;
    }
    
}